package com.zhang.apidriver.controller;

import com.zhang.apidriver.service.VerificationCodeService;
import com.zhang.internalcommon.dto.ResponseResult;
import com.zhang.internalcommon.dto.VerificationCodeDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 类功能描述
 *
 * @author Kye
 * @date 2025-04-13
 */
@RestController
public class VerificationCodeController {
	@Autowired
	VerificationCodeService verificationCodeService;

	@PostMapping("/verification-code")
	public ResponseResult verificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO) {
		String driverPhone = verificationCodeDTO.getDriverPhone();
		return verificationCodeService.checkAndsendVerificationCode(driverPhone);
	}

	@CrossOrigin
	@PostMapping("/verification-code-check")
	public ResponseResult verificationCodeCheck(@RequestBody VerificationCodeDTO verificationCodeDTO) {
		String driverPhone = verificationCodeDTO.getDriverPhone();
		String verificationCode = verificationCodeDTO.getVerificationCode();
		ResponseResult responseResult = verificationCodeService.checkVerificationCode(driverPhone, verificationCode);
		return responseResult;
	}
}
